# ---------------------------------------------------------------------- #
# Add tables                                                             #
# ---------------------------------------------------------------------- #

# ---------------------------------------------------------------------- #
# Add table "dezrepo_permissions"                                        #
# ---------------------------------------------------------------------- #

CREATE TABLE `dezrepo_permissions` (
    `prm_username` VARCHAR(50) NOT NULL,
    `prm_projectfilename` VARCHAR(250) NOT NULL,
    `permission` VARCHAR(50),
    PRIMARY KEY (`prm_username`, `prm_projectfilename`)
);

# ---------------------------------------------------------------------- #
# Add table "dezrepo_projects"                                           #
# ---------------------------------------------------------------------- #

CREATE TABLE `dezrepo_projects` (
    `projectfilename` VARCHAR(250) NOT NULL,
    `projectname` VARCHAR(250) NOT NULL,
    `projectdescription` VARCHAR(250),
    `latestversion` NUMERIC,
    `lockedby` VARCHAR(50),
    `lockeddate` VARCHAR(20),
    `lastupdateby` VARCHAR(50),
    `lastupdatedate` VARCHAR(20),
    `dezignversionnumber` VARCHAR(10),
    PRIMARY KEY (`projectfilename`)
);

# ---------------------------------------------------------------------- #
# Add table "dezrepo_projectversions"                                    #
# ---------------------------------------------------------------------- #

CREATE TABLE `dezrepo_projectversions` (
    `prv_projectfilename` VARCHAR(250) NOT NULL,
    `versionnumber` NUMERIC NOT NULL,
    `commitdate` VARCHAR(20),
    `prv_username` VARCHAR(50),
    `projectdata` LONGBLOB,
    `changecomment` VARCHAR(250),
    `dezignversionnumber` VARCHAR(10),
    PRIMARY KEY (`prv_projectfilename`, `versionnumber`)
);

# ---------------------------------------------------------------------- #
# Add table "dezrepo_settings"                                           #
# ---------------------------------------------------------------------- #

CREATE TABLE `dezrepo_settings` (
    `settingname` VARCHAR(30) NOT NULL,
    `settingvalue` VARCHAR(100),
    PRIMARY KEY (`settingname`)
);

# ---------------------------------------------------------------------- #
# Add table "dezrepo_users"                                              #
# ---------------------------------------------------------------------- #

CREATE TABLE `dezrepo_users` (
    `username` VARCHAR(50) NOT NULL,
    `userpassword` VARCHAR(50),
    `lastlogindate` VARCHAR(20),
    `userrights` VARCHAR(100),
    `defaultpermission` VARCHAR(20),
    PRIMARY KEY (`username`)
);
